<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/6/6
 * Time: 18:30
 */

namespace XiaoZhuBundle\Model;


class Config
{
    private $REQUEST;
    private $DOCTRINE;

    public function __construct($REQUEST,$DOCTRINE)
    {
        $this->REQUEST = $REQUEST->getCurrentRequest();
        $this->DOCTRINE = $DOCTRINE;
    }

    public function db()
    {
        return $this->DOCTRINE->getManager()->createQueryBuilder();
    }

    public function rep($entityName)
    {
        return $this->DOCTRINE->getManager()->getRepository($entityName);
    }

    public function get($key)
    {
        $rep = $this->rep("AdminsBundle:SiteSetting");
        $config = $rep->findOneBy(array("key"=>$key));
        return $config->getValue();
    }

}